package com.playcrab.adouban;

import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TabHost;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.app.TabActivity;
import com.google.gdata.client.douban.DoubanService;
import com.playcrab.adouban.util.Constants;

public class Collection  extends TabActivity {
    /** Called when the activity is first created. */
	 private TabHost tabs;

    private static final String LOG_TAG = "Collection";
        
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.collection);
        
        Bundle bundle = this.getIntent().getExtras();
        String type = bundle.getString("type");
        String query = bundle.getString("q");
        Log.v(LOG_TAG,"type:"+type);
        Log.v(LOG_TAG,"query:"+query);
        
        tabs = getTabHost();        
        TabHost.TabSpec bookTab = tabs.newTabSpec("book");
        Intent book = new Intent(this, CollectionList.class);
        book.putExtra("q", query);
        book.putExtra("type", "book");
        bookTab.setContent(book);
        bookTab.setIndicator("", this.getResources().getDrawable(R.drawable.book));
        tabs.addTab(bookTab);

        TabHost.TabSpec movieTab = tabs.newTabSpec("movie");
        Intent movie = new Intent(this, CollectionList.class);
       
        movie.putExtra("q", query);
        movie.putExtra("type", "movie");
        movieTab.setContent(movie);
        movieTab.setIndicator("", this.getResources().getDrawable(R.drawable.movie));
        tabs.addTab(movieTab);
        
        TabHost.TabSpec musicTab = tabs.newTabSpec("music");
        Intent music = new Intent(this, CollectionList.class);
        music.putExtra("q", query); 
        music.putExtra("type", "music");
        musicTab.setContent(music);
        musicTab.setIndicator("", this.getResources().getDrawable(R.drawable.music));
        tabs.addTab(musicTab);
          
		 
        if(type.equalsIgnoreCase("book")){
        	tabs.setCurrentTab(0);
        }else if(type.equalsIgnoreCase("movie")){
        	tabs.setCurrentTab(1);
        }else if(type.equalsIgnoreCase("music")){
        	tabs.setCurrentTab(2);
        }else{
        	tabs.setCurrentTab(0);
        }
          
		
    }
       
}